#ifndef     __PROTO_H
#define     __PROTO_H

#include "./conn_info.h"

namespace conn::proto {

constexpr uint16_t HEAD = 0xE11E;
constexpr uint8_t END = 0xEF;

constexpr uint8_t REQ_ACK = 0x00;
constexpr uint8_t REQ_GET_TASK_INFO = 0x01;
constexpr uint8_t REQ_LOG = 0x02;
constexpr uint8_t REQ_OTA_START = 0x03;
constexpr uint8_t REQ_OTA_TRANSLATE = 0x04;
constexpr uint8_t REQ_OTA_COMPLETE = 0x05;
constexpr uint8_t REQ_PING = 0x06;
constexpr uint8_t REQ_PREPROG = 0x07;
constexpr uint8_t REQ_UPLOAD_STATUS = 0x08;

// 落杯
constexpr uint8_t REQ_PIPE_LINE_DROP_CUP = 0x09;

// 流水线电机控制
constexpr uint8_t REQ_PIPE_LINE_MOTOR_CTRL = 0x0A;

// 制冰 抽水控制
constexpr uint8_t REQ_ICE_DRAW_CTRL = 0x0B;

// 制冰 制冰控制
constexpr uint8_t REQ_ICE_MAKE_CTRL = 0x0C;

// 制冰 组件测试
constexpr uint8_t REQ_ICE_PARTS_CTRL = 0x0D;

// 取物门 初始化
constexpr uint8_t REQ_PICK_INIT = 0x0E;

// 取物门 门测试
constexpr uint8_t REQ_PICK_DOOR_CTRL = 0x0F;

// 取物门 灯测试
constexpr uint8_t REQ_PICK_LED_CTRL = 0x10;

// 取物门 出货
constexpr uint8_t REQ_PICK_DO = 0x11;

// 加热 抽水控制
constexpr uint8_t REQ_HEAT_DRAW_CTRL = 0x12;

// 加热 搅拌盒控制
constexpr uint8_t REQ_HEAT_STIR_BOX_CTRL = 0x13;

// 加热 截热水电机控制
constexpr uint8_t REQ_HEAT_WATER_MOTOR_CTRL = 0x14;

// 加热 截冰电机控制
constexpr uint8_t REQ_HEAT_ICE_MOTOR_CTRL = 0x15;

// 加热 组件测试
constexpr uint8_t REQ_HEAT_PARTS_CTRL = 0x16;

// 加热 初始化
constexpr uint8_t REQ_HEAT_INIT = 0x17;

// 加热 设置流量计参数
constexpr uint8_t REQ_HEAT_SET_FLOW = 0x18;

// 加热 查询流量计参数
constexpr uint8_t REQ_HEAT_GET_LOW = 0x19;

// 加热 出水测试
constexpr uint8_t REQ_HEAT_DRAW_WATER = 0x1A;

// 加热 出货预加热
constexpr uint8_t REQ_HEAT_PRE_HEAT_CTRL = 0x1B;

// 加热 释放蒸汽
constexpr uint8_t REQ_HEAT_DROP_STEAM = 0x1C;

// 加热 搅拌茶粉
constexpr uint8_t REQ_HEAT_STIR_POWDER = 0x1D;

// 机械臂 测试升降电机
constexpr uint8_t REQ_ARM_ELEVATOR_CTRL = 0x1E;

// 机械臂 测试夹爪
constexpr uint8_t REQ_ARM_JAW_CTRL = 0x1F;

// 机械臂 测试机械手
constexpr uint8_t REQ_ARM_ARM_CTRL = 0x20;

// 机械臂 测试机械臂运动
constexpr uint8_t REQ_ARM_ARM_RUN_CTRL = 0x21;

// 机械臂 测试封膜
constexpr uint8_t REQ_ARM_FILM_CTRL = 0x22;

// 机械臂 出货
constexpr uint8_t REQ_ARM_PICK = 0x23;

// 机械臂 初始化
constexpr uint8_t REQ_ARM_INIT = 0x24;

// 粉料架 测试升降电机
constexpr uint8_t REQ_POWDER_UPDOWM_CTRL = 0x25;

// 粉料架 测试倾倒电机
constexpr uint8_t REQ_POWDER_DUMP_CTRL = 0x26;

// 粉料架 测试移动电机
constexpr uint8_t REQ_POWDER_MOVE_CTRL = 0x27;

// 粉料架 测试货架电机
constexpr uint8_t REQ_POWDER_CARGO_CTRL = 0x28;

// 粉料架 测试压紧电磁铁
constexpr uint8_t REQ_POWDER_ELOCK_CTRL = 0x29;

// 粉料架 初始化
constexpr uint8_t REQ_POWDER_INIT = 0x2A;

// 粉料架 取货
constexpr uint8_t REQ_POWDER_PICK = 0x2B;

// 制冰板 出冰
constexpr uint8_t REQ_ICE_DROP_ICE = 0x2C;

// 加热 清洗
constexpr uint8_t REQ_HEAT_CLEAN = 0x2D;

// 加热 预放水
constexpr uint8_t REQ_HEAT_PRE_WATER = 0x2E;

uint8_t set_rs232_head(uint8_t *buf, uint8_t data_len, const ConnInfo &conn_info);

enum class SplitProtoRet : uint8_t {
    NEXT = 0x01,
    FAIL = 0x02,
};

SplitProtoRet split_proto(const uint8_t *buf, uint8_t len, uint8_t &index);

}

#endif
